package com.canieatit.app;

import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

import com.example.android.actionbarcompat.ActionBarActivity;

public class ParentActivity extends ActionBarActivity {
	
	protected static final String EXTRA_BARCODE_NUMBER = "barcodeNumber";
	protected static final String EXTRA_BARCODE_FORMAT = "barcodeFormat";
	protected static final String TESTING_FORMAT = "ean_13";
	protected static final String TESTING_BARCODE = "03333408408";
	protected static final String RESTLET_BASE_URL = "http://can-i-eat-it.appspot.com/product?";
//	protected static final String RESTLET_TEST_URL = "http://can-i-eat-it.appspot.com/product?barcode=" + TESTING_BARCODE + "&format="+TESTING_FORMAT;
	protected static final String RESTLET_TEST_URL = "http://192.168.1.2:8888/product?barcode=" + TESTING_BARCODE + "&format="+TESTING_FORMAT;
//	protected static final String RESTLET_TEST_URL = "http://169.254.0.3:8888/product?barcode=" + TESTING_BARCODE + "&format="+TESTING_FORMAT;

	
	
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.main, menu);

        // Calling super after populating the menu is necessary here to ensure that the
        // action bar helpers have a chance to handle this event.
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                Toast.makeText(this, "Tapped home", Toast.LENGTH_SHORT).show();
                break;

            case R.id.menu_refresh:
                Toast.makeText(this, "Fake refreshing...", Toast.LENGTH_SHORT).show();
                getActionBarHelper().setRefreshActionItemState(true);
                getWindow().getDecorView().postDelayed(
                        new Runnable() {
                            @Override
                            public void run() {
                                getActionBarHelper().setRefreshActionItemState(false);
                            }
                        }, 1000);
                break;

            case R.id.menu_search:
                Toast.makeText(this, "Tapped search", Toast.LENGTH_SHORT).show();
                break;

            case R.id.menu_share:
                Toast.makeText(this, "Tapped share", Toast.LENGTH_SHORT).show();
                break;
        }
        return super.onOptionsItemSelected(item);
    }
	
}
